package com.more.offer.threadtest.volatiletest;

import com.more.offer.threadtest.reentrantlocktest.ReadWriteLockList;
import javafx.scene.paint.Stop;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author pinoc
 * @date 2021/11/16
 * @description 这里测试不能使用system.out.println打印 println使用了synchronized 锁，会将cpu缓存置为失效并读主内存
 */
public class Package {

	private static List<String> flag3 = new ArrayList<>();
	private static long count = 0;
	public static void main(String[] args) throws InterruptedException {
		for (int i = 0; i < 1; i++) {
			new Thread(()->{
				while (flag3.size() == 0) {
					count++;
					if(count > 19000000000L) {
						break;
					}
				}
				System.out.println("满足停止条件 count " + count);
			}).start();
		}
		System.out.println("set flag2: "+System.currentTimeMillis());
		Thread.sleep(1000);
		flag3.add("1");
	}
}
